import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from 'alinesno-ui/packages/Layout/layout'
import Login from 'alinesno-ui/packages/Login/Login'

Vue.use(VueRouter)

// >>>>>>>>>>> TODO 提取出公共路由 >>>>>>>>>>>>>>>>
export const constantRoutes = [
  {

    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/dashboard/home'], resolve),
        name: '首页'
      },
      {
        path: '/github/callback',
        component: (resolve) => require(['@/views/dashboard/home'], resolve),
        name: '/github/callback',
        hidden: true
      },
      {
        path: '/dashboard/user/profile',
        component: (resolve) => require(['alinesno-ui/packages/Ucenter/profile/index'], resolve),
        name: '用户中心',
        hidden: true ,
        meta: { title: '用户中心', icon: 'fas fa-chalkboard', noCache: true, affix: true }
      },
      {
        path: '/dashboard/document',
        component: (resolve) => require(['alinesno-ui/src/views/dashboard/document'], resolve),
        name: '文档服务',
        hidden: true
      },
      
      {
        path: '/com/alinesno/cloud/business/buildGit/list',
        component: (resolve) => require(['@/views/com/alinesno/cloud/business/buildGit/list'], resolve),
        name: 'com/alinesno/cloud/business/buildGit/list',
        meta: {title:'绑定仓库'},
        hidden: true
      },
      {
        path: '/dashboard/notifications',
        component: (resolve) => require(['alinesno-ui/src/views/dashboard/notifications'], resolve),
        name: '消息管理',
        hidden: true
      },
      {
        path: '/dashboard/workorder',
        component: (resolve) => require(['alinesno-ui/src/views/dashboard/workorder'], resolve),
        name: '工单管理',
        hidden: true
      },
      {
        path: '/dashboard/platform/service',
        component: (resolve) => require(['alinesno-ui/src/views/dashboard/service/Support'], resolve),
        name: '支持管理',
        hidden: true
      }
    ]
  },
  {
    path: '/app',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/build/app/index',
        component: (resolve) => require(['@/views/dashboard/app/index'], resolve),
        name: '创建移动应用'
      },
      {
        path: '/build/app/gitlab',
        component: (resolve) => require(['@/views/dashboard/app/gitlab'], resolve),
        name: '连接仓库'
      },
      {
        path: '/build/app/model',
        component: (resolve) => require(['@/views/dashboard/app/model'], resolve),
        name: '模型管理'
      },
      {
        path: '/build/app/overview',
        component: (resolve) => require(['@/views/dashboard/app/overview'], resolve),
        name: '组件空间'
      },
      {
        path: '/build/app/config',
        component: (resolve) => require(['@/views/dashboard/app/config'], resolve),
        name: '配置管理'
      },
      {
        path: '/build/app/deploy',
        component: (resolve) => require(['@/views/dashboard/app/deploy'], resolve),
        name: '应用发布'
      }
    ]
  },
  {
    path: '/build',
    component: Layout,
    hidden: true,
    meta: {title: '应用构建', icon: 'dashboard', noCache: true, affix: true},
    children: [
      {
        path: '/build/projectInfo/:fromWhere',
        component: (resolve) => require(['@/views/dashboard/projectInfo'], resolve),
        meta: {title: '应用信息', icon: 'dashboard', noCache: true, affix: true},
        name: '应用信息'
      },
      {
        path: '/build/genSeedProject',
        component: (resolve) => require(['@/views/com/alinesno/cloud/initializr/initiallizrSeed/genProject'], resolve),
        meta: {title: '创建脚手架', icon: 'dashboard', noCache: true, affix: true},
        name: '创建脚手架'
      },
      {
        path: '/build/component',
        component: (resolve) => require(['@/views/dashboard/component'], resolve),
        meta: {title: '创建应用', icon: 'dashboard', noCache: true, affix: true},
        name: '创建应用'
      },
      {
        path: '/build/connectGit/:pId',
        component: (resolve) => require(['@/views/dashboard/connectGit'], resolve),
        meta: {title: '连接gitlab账号', icon: 'dashboard', noCache: true, affix: true},
        name: '连接gitlab账号'
      },
      {
        path: '/build/overview/:pId',
        component: (resolve) => require(['@/views/dashboard/overview'], resolve),
        meta: {title: '应用组件空间', icon: 'dashboard', noCache: true, affix: true},
        name: '应用组件空间'
      },
      {
        path: '/build/information/:pId',
        component: (resolve) => require(['@/views/dashboard/information'], resolve),
        meta: {title: '项目信息', icon: 'dashboard', noCache: true, affix: true},
        name: '项目信息'
      },
      {
        path: '/com/alinesno/cloud/business/buildApplication/list',
        component: (resolve) => require(['@/views/com/alinesno/cloud/business/buildApplication/list'], resolve),
        meta: {title: '应用管理', icon: 'dashboard', noCache: true, affix: true},
        name: '应用管理'
      },
      {
        path: '/com/alinesno/cloud/initializr/db/database/list' , 
        component: (resolve) => require(['@/views/com/alinesno/cloud/initializr/db/database/list'], resolve),
        meta: {title: '数据库管理', icon: 'dashboard', noCache: true, affix: true},
        name: '数据库管理'
      },
      {
        path: '/com/alinesno/cloud/business/buildGit/list' , 
        component: (resolve) => require(['@/views/com/alinesno/cloud/business/buildGit/list'], resolve),
        meta: {title: '仓库管理', icon: 'dashboard', noCache: true, affix: true},
        name: '仓库管理'
      },
      {
        path: '/build/deploy/:pId',
        component: (resolve) => require(['@/views/dashboard/deploy'], resolve),
        meta: {title: '发布', icon: 'dashboard', noCache: true, affix: true},
        name: '发布'
      },
      {
        path: '/build/com/alinesno/cloud/initializr/initiallizrSeed/connectCicd/:pId',
        component: (resolve) => require(['@/views/com/alinesno/cloud/initializr/initiallizrSeed/connectCicd'], resolve),
        meta: {title: '一键发布', icon: 'dashboard', noCache: true, affix: true},
        name: '一键发布'
      }
    ]
  },
  {
    path: '/gen',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:dbName/:tableId(\\d+)',
        component: (resolve) => require(['@/views/com/alinesno/cloud/initializr/codeGenertor/editTable'], resolve),
        name: 'GenEdit',
        meta: {title: '修改生成配置'}
      },
      {
        path: 'form',
        component: (resolve) => require(['@/views/dashboard/form'], resolve),
        name: 'GenEdit',
        meta: {title: '修改生成配置'}
      }
    ]
  },
  {
    path: '/login',
    component: Login,
    hidden: true
  },

  {
    path: '/404',
    component: (resolve) => require(['alinesno-ui/src/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['alinesno-ui/src/views/error/401'], resolve),
    hidden: true
  }
]

export default new VueRouter({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})
